#ifndef PICKUP_CONTROL_H
#define PICKUP_CONTROL_H

class PickupControl;

#include <vector>
#include "Pickup.h"

// state constants
#define PU_ACTIVE   (0)
#define PU_EXPIRED  (1)
#define PU_INACTIVE (2)

typedef struct PickupState {
    int state;
    Ogre::Real update_time;
} PickupState ;

class PickupControl : public OgreNewt::ContactCallback, public Ogre::FrameListener
{
    private:
        Player *player;
        OgreNewt::World *world;
        static OgreNewt::MaterialPair *ball_mat_pair;
        std::vector<Pickup*> *pickups;
        std::vector<PickupState> pickup_states;
        std::list<unsigned> active_pickups;
        Ogre::Real time;
        
        //int userBegin();
        
    public:
    
        PickupControl(std::vector<Pickup*> *pi, OgreNewt::World *w);
       ~PickupControl(void);
        void addMatPair(OgreNewt::MaterialID *other_mat_id);
        void reset();
        
        void setPlayer(Player *pl) { player = pl; }
        Player *getPlayer() { return player; }
        
        void addPickup(Pickup *p);
        void setRespawnTime(Ogre::String name, Ogre::Real r);
        void setActiveTime(Ogre::String name, Ogre::Real t);
        void pickupHit(unsigned id);
        PickupControl* clone(void);
	    bool frameStarted(Ogre::Real t);
	    void setPlayState(PlayState *ps);
};

#endif
